package objectoriented2;

import javafx.scene.effect.PerspectiveTransform;

class Person{}
interface worK{}
interface play{}
class SocialPerson extends Person implements worK,play{}
interface HopeWork extends worK,play{}



/*
接口

规范行为

 */
//动物的行为规范
//行为如何实现，不知道是哪一种宠物，没有办法实现
interface  AnimalAction{
    //抽像的方法
    void eat();
    void play();
    void speak();
}
//子类继承接口，实现接口中的行为，
//extends继承父类，implements接口
 class Dog implements AnimalAction{


    @Override
    public void eat() {
        System.out.println("狗吃骨头");
    }

    @Override
    public void play() {
        System.out.println("狗玩飞盘");

    }

    @Override
    public void speak() {
        System.out.println("小狗汪汪叫");

    }
}

class Cat implements AnimalAction{
    @Override
    public void eat() {
        System.out.println("猫吃鱼");
    }

    @Override
    public void play() {
        System.out.println("猫玩球");
    }

    @Override
    public void speak() {
        System.out.println("小猫喵喵叫");
    }
}
class User{
    /*


    //方法参数----形式参数
    public void raiseAnimal(Dog dog){
        dog.eat();
        dog.play();
        dog.speak();
    }
    public void raiseAnimal(Cat cat){
        cat.eat();
        cat.play();
        cat.speak();
    }
    */
    //形参-是Dog和Cat的父类----接口
    public  void raiseAnimal(AnimalAction animal){
        animal.eat();
        animal.play();
        animal.speak();
    }





}

class Fish implements  AnimalAction{
    @Override
    public void eat() {

    }

    @Override
    public void play() {

    }

    @Override
    public void speak() {

    }
}

class Bird{}

public class TestInterface {
    public static void main(String[] args) {
        User user=new User();
        Dog dog=new Dog();
        Cat kitty=new Cat();
        //调用方法---实在参数
        user.raiseAnimal(dog);
        /*


        AnimalAction pet= new AnimalAction() {
            @Override
            public void eat() {

            }

            @Override
            public void play() {

            }

            @Override
            public void speak() {

            }
        };
        */
    }
}
